package cn.tedu.csmall.stock.webapi.quartz;

import cn.tedu.csmall.stock.webapi.quartz.config.RabbitMQConfiguration;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
//RabbitMQ要在类上编写监听器
//监听STOCK_QUEUE队列,一旦队列有消息,就去运行指定方法
@RabbitListener(queues = {RabbitMQConfiguration.STOCK_QUEUE})

public class RabbitMQConsumer {
    //这个类中只允许一个方法添加这个注解
    @RabbitHandler
    public void process(String str){


        System.out.println("消费者接收到信息"+str);
    }


}
